package _2_2基础算法;

import java.util.Scanner;

public class _377计数问题 {
	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt(); // 一共有多少数字 1-n
		int x = scan.nextInt(); // 需要判断的数字（0-9
		String num = String.valueOf(x);
		int numCount = 0;
		for(int i = 1;i <= n;i++) {
			String s = String.valueOf(i);
			for(int j = 0;j < s.length();j++) {
				String charForString = String.valueOf(s.charAt(j));
				if(charForString.equals(num)) {
					numCount++;
				}
			}
		}
		System.out.println(numCount);
		scan.close();

	}
}
